﻿@model MaintenanceModel

@{
    //page title
    ViewBag.PageTitle = T("Admin.System.Maintenance").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Maintenance");
}

@{
    const string hideDeleteGuestsBlockAttributeName = "MaintenancePage.HideDeleteGuestsBlock";
    var hideDeleteGuestsBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideDeleteGuestsBlockAttributeName);

    const string hideDeleteFilesBlockAttributeName = "MaintenancePage.HideDeleteFilesBlock";
    var hideDeleteFilesBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideDeleteFilesBlockAttributeName);

    const string hideDeleteCartsBlockAttributeName = "MaintenancePage.HideDeleteCartsBlock";
    var hideDeleteCartsBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideDeleteCartsBlockAttributeName);

    const string hideReindexBlockAttributeName = "MaintenancePage.HideReindexBlock";
    var hideReindexBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideReindexBlockAttributeName);

    const string hideBackupsBlockAttributeName = "MaintenancePage.HideBackupsBlock";
    var hideBackupsBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideBackupsBlockAttributeName);

    const string hideDeleteAlreadySentQueuedEmailsBlockAttributeName = "MaintenancePage.HideDeleteAlreadySentQueuedEmailsBlock";
    var hideDeleteAlreadySentQueuedEmailsBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideDeleteAlreadySentQueuedEmailsBlockAttributeName);
}

<div class="content-header clearfix">
    <h1 class="pull-left">
        @T("Admin.System.Maintenance")
    </h1>
    <div class="pull-right">
        &nbsp;
        @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.MaintenanceButtons })
    </div>
</div>

<form asp-controller="Common" asp-action="Maintenance" method="post">
    <input type="hidden" asp-for="BackupSupported" />
    <div class="content">
        <div class="form-horizontal">
            <nop-panels id="maintenance-panels">
                <div class="row">
                    <nop-panels id="maintenance-firstline-panels">
                        <nop-panel class="col-md-6 col-xs-12 margin-t-5" asp-name="maintenance-delete-guests" asp-icon="fa fa-trash" asp-title="@T("Admin.System.Maintenance.DeleteGuests")" asp-hide-block-attribute-name="@hideDeleteGuestsBlockAttributeName" asp-hide="@hideDeleteGuestsBlock" asp-advanced="false">@await Html.PartialAsync("_Maintenance.DeleteGuests", Model)</nop-panel>
                        <nop-panel class="col-md-6 col-xs-12 margin-t-5" asp-name="maintenance-delete-files" asp-icon="fa fa-trash" asp-title="@T("Admin.System.Maintenance.DeleteExportedFiles")" asp-hide-block-attribute-name="@hideDeleteFilesBlockAttributeName" asp-hide="@hideDeleteFilesBlock" asp-advanced="false">@await Html.PartialAsync("_Maintenance.DeleteFiles", Model)</nop-panel>
                    </nop-panels>
                </div>
                <div class="row">
                    <nop-panels id="maintenance-secondline-panels">
                        <nop-panel class="col-md-6 col-xs-12 margin-t-5" asp-name="maintenance-delete-carts" asp-icon="fa fa-trash-o" asp-title="@T("Admin.System.Maintenance.DeleteAbandonedCarts")" asp-hide-block-attribute-name="@hideDeleteCartsBlockAttributeName" asp-hide="@hideDeleteCartsBlock" asp-advanced="false">@await Html.PartialAsync("_Maintenance.DeleteAbandonedCarts", Model)</nop-panel>
                        <nop-panel class="col-md-6 col-xs-12 margin-t-5" asp-name="maintenance-reindex" asp-icon="fa fa-database" asp-title="@T("Admin.System.Maintenance.ReIndexTables")" asp-hide-block-attribute-name="@hideReindexBlockAttributeName" asp-hide="@hideReindexBlock" asp-advanced="false">@await Html.PartialAsync("_Maintenance.ReindexDatabaseTables", Model)</nop-panel>
                    </nop-panels>
                </div>
                <div class="row">
                    <nop-panels id="maintenance-thirdline-panels">
                        @if (Model.BackupSupported)
                        {
                            <nop-panel class="col-md-6 col-xs-12 margin-t-5" asp-name="maintenance-backups" asp-icon="fa fa-hdd-o" asp-title="@T("Admin.System.Maintenance.BackupDatabase.DatabaseBackups")" asp-hide-block-attribute-name="@hideBackupsBlockAttributeName" asp-hide="@hideBackupsBlock" asp-advanced="false">@await Html.PartialAsync("_Maintenance.DBBackups", Model)</nop-panel>
                        }
                        <nop-panel class="col-md-6 col-xs-12 margin-t-5" asp-name="maintenance-delete-already-sent-queued-emails" asp-icon="fa fa-trash" asp-title="@T("Admin.System.Maintenance.DeleteAlreadySentQueuedEmails")" asp-hide-block-attribute-name="@hideDeleteAlreadySentQueuedEmailsBlockAttributeName" asp-hide="@hideDeleteAlreadySentQueuedEmailsBlock" asp-advanced="false">@await Html.PartialAsync("_Maintenance.DeleteAlreadySentQueuedEmails", Model)</nop-panel>
                    </nop-panels>
                </div>
                @await Component.InvokeAsync("AdminWidget", new {widgetZone = AdminWidgetZones.MaintenanceDetailsBlock, additionalData = Model})
            </nop-panels>
        </div>
    </div>
</form>